package com.huowei.htzy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.huowei.htzy.R;
import com.huowei.htzy.fragment.Drugs;
import com.huowei.htzy.util.GlideUtil;
import com.huowei.htzy.util.ViewHolderUtil;

import java.util.List;

/**
 * Created by huowei on 2016/10/13.
 */

public class ClassAdapter extends BaseAdapter {
    private List<Drugs.ClassListBean> listBeen ;
    private Context context;

    public ClassAdapter(List<Drugs.ClassListBean> listBeen, Context context) {
        this.listBeen = listBeen;
        this.context = context;
    }

    @Override
    public int getCount() {
        return listBeen.size();
    }

    @Override
    public Object getItem(int position) {
        return listBeen.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            convertView = LayoutInflater.from(context).inflate(R.layout.class_list_iten1,null);
        }
        TextView typeDesc = ViewHolderUtil.get(convertView, R.id.class_adapter1_typeDesc);
        TextView typeDTitle = ViewHolderUtil.get(convertView, R.id.class_adapter1_typeTitleName);
        ImageView imagePic = ViewHolderUtil.get(convertView, R.id.class_adapter1_imagePic);
        Drugs.ClassListBean bean = listBeen.get(position);
        typeDTitle.setText(bean.getGc_name());
        typeDesc.setText(bean.getText());
        GlideUtil.setRequest(context,bean.getImage(),imagePic);
        return convertView;
    }
}
